//package io.mvvm.security.service.impl;
//
//import io.mvvm.common.entity.SelfUserDetails;
//import io.mvvm.security.service.IRbacAuthorityService;
//import io.mvvm.security.service.IUserDetailsService;
//import org.springframework.security.core.Authentication;
//import org.springframework.stereotype.Service;
//import org.springframework.util.AntPathMatcher;
//
//import javax.annotation.Resource;
//import javax.servlet.http.HttpServletRequest;
//import java.util.Set;
//
///**
// * @program: seize-login
// * @description:
// * @author: 潘
// * @create: 2021-05-14 22:47
// **/
//@Service("rbacAuthorityService")
//public class RbacAuthorityServiceImpl implements IRbacAuthorityService {
//
//    @Resource
//    private IUserDetailsService iUserDetailsService;
//
//    @Override
//    public boolean hasPermission(HttpServletRequest request, Authentication authentication) {
//
//        final String requestUrl = request.getRequestURI();
//
//        Object userInfo = authentication.getPrincipal();
//
//        if (userInfo instanceof SelfUserDetails) {
//            String username = ((SelfUserDetails) userInfo).getUsername();
//            //获取资源
//            Set<String> urls = iUserDetailsService.getMenusByUserName(username);
//            // 路径匹配器
//            AntPathMatcher antPathMatcher = new AntPathMatcher();
//            for (String url : urls) {
//                if (antPathMatcher.match(url, requestUrl)) {
//                    return true;
//                }
//            }
//        }
//
//        return false;
//    }
//}
